﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Campus.Main.Basic.Settings;

namespace Campus.Main.Basic.InsertValues
{
    public partial class Room : Default
    {
        public Room()
        {
            InitializeComponent();
        }
        public Room(List<string> item)
            : base(item)
        {
            InitializeComponent();
            aToDb.AddItem(comboBox1,"yurtdef");
            aToDb.AddItem(comboBox2,"pol");
            comboBox1.SelectedValue = item[1];
            textBox1.Text = item[3];
            comboBox2.SelectedValue = item[2];
        }

        protected override void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length > 0)
            {
                int val2 = Convert.ToInt32(comboBox1.SelectedValue);
                int val3 = Convert.ToInt32(comboBox2.SelectedValue);
                string val1 = textBox1.Text;
                aToDb.UpdateRoom(val1,val2,val3,id);
                //aToDb.UpdateTable("room", "description", "yurt_id","pol_id", val1, val2,val3, id);
                MessageBox.Show("Duzenlendi");
                Close();
            }
            else
            {
                MessageBox.Show("Таллана толтургула");
                textBox1.Focus();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string room = id;
            var temp = new List<string>();
            BedCountForm f;
            string count = aToDb.SelectField("SELECT COUNT(*) FROM bed WHERE room_id=" + room);
            if (count != "0")
            {
                temp.Add(room);
                temp.Add(count);
                f = new BedCountForm(temp);
            }
            else
            {
                f=new BedCountForm(room);
            }
            f.ShowDialog();
        }
        
    }
}
